package liangtWorkSpace.Observer.HeadFiestObsver.display;

import liangtWorkSpace.Observer.HeadFiestObsver.subject.Subject;

/**
 * @ClassName StatisticsDisplay
 * @Description : 统计展示布告栏
 * @Author : LiangT
 * @Date : 2020/6/17 20:11
 */
public class StatisticsDisplay implements DisplayElement,Observer{
    /* 湿度 */
    private float humidity;
    /* 气压 */
    private float pressure;
    /* 温度 */
    private float tempreature;
    /* 气象站 */
    private Subject weather;

    /**
     * 构造函数将自己注册到气象站中，获取气象站数据变化通知
     * @param weather
     */
    public StatisticsDisplay(Subject weather) {
        this.weather = weather;
        weather.registerObserver(this);
    }

    /**
     * 将本气象站的信息展示
     */
    @Override
    public void disPlay() {
        System.out.println("Statistics: pressure="+pressure
        +" humidity = "+ humidity+"% ");
    }

    /**
     * 更新布告栏信息并调用展示
     * @param temp
     * @param hunidity
     * @param pressure
     */
    @Override
    public void update(float temp, float hunidity, float pressure) {
        this.humidity=hunidity;
        this.pressure = pressure;
        disPlay();
    }
}
